<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    table {
        position: absolute;
        width: 300px;
        height: 150px;
        text-align: center;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        margin: auto;
    }
</style>

<body>

    <table border="1px" cellspacing=0>
        <tr>
            <td>111</td>
            <td>111</td>
            <td>111</td>
        </tr>
        <tr>
            <td>222</td>
            <td>222</td>
            <td>222</td>
        </tr>
        <tr>
            <td>333</td>
            <td>333</td>
            <td>333</td>
        </tr>
        <tr>
            <td>444</td>
            <td>444</td>
            <td>444</td>
        </tr>
    </table>
    <script>
        window.onload = function () {
            var trs = document.querySelectorAll('tr')
            for (var i = 0; i < trs.length; i++) {
                if (i % 2 == 0) {
                    trs[i].style.background = 'pink'
                } else {
                    trs[i].style.background = 'yellow'
                }
            }

        }

    </script>
</body>

</html>